package main

import (
	"fmt"
	"net/http"
	_ "net/http/pprof"

	log "github.com/Sirupsen/logrus"
)

func main() {
	go func() {
		port := randPort()
		log.Printf("pprof port: %d", port)
		log.Println(http.ListenAndServe(fmt.Sprintf(":%d", port), nil))
	}()
	InitLog()
	log.Debugf("config: %+v", Conf)
	var worker *Worker
	var err error
	go func() {
		worker, err = NewWorker()
		if err != nil {
			log.Fatalf("new worker error: %s", err.Error())
		}
		err = worker.RegisterIdent()
		if err != nil {
			log.Fatalf("worker register ident error: %s", err.Error())
		}
		worker.Run()
	}()
	//worker.TestSend()
	worker.HandleSignal()
}
